﻿using System;
using System.Linq;
namespace HW4_d2
{
    class Program
    {
        static void Main(string[] args)
        {
            Random rnd = new Random();
            // 生成100个1-1000之间的整数，保存在num数组中
            int[] num = new int[100];
            for(int i = 0; i < 100; i++)
            {
                num[i] = rnd.Next(1, 1001);
            }
            // LINQ对随机数排序
            var query = from n in num
                        orderby n descending
                        select n;
            // 求和
            int sum = query.Sum();
            // 求平均
            double avg = query.Average();
            foreach(int n in query)
            {
                Console.WriteLine(n);
            }
            Console.WriteLine($"平均数：{avg}");
            Console.WriteLine($"和：{sum}");
        }
    }
}
